import { observable, action } from 'mobx';
import { WeaTableNew } from 'comsMobx';

const { TableStore } = WeaTableNew;
import { WeaTools } from 'ecCom';

import ListBaseStore from './ListBaseStore';
import Apis from '../apis/car';
import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;
/**
 * 车辆查询Store
 */
export default class CarUseCarWorkflowSetStore extends ListBaseStore {
  constructor() {
    super();
    this.selectedKey = 'all';
  }

	@observable queckSearch = '';
	@observable carbasicid = 0;
	@observable subCompanyId = 0;
	@observable isRight=1;

	@action
	setQueckSearch=(params) => {
	  this.queckSearch = params.queckSearch;
	  this.subCompanyId = params.subCompanyId;
	}


    getWorkflowDetachable = (callbackfun) => {
      Apis.getWorkflowDetachable().then(
        (result) => {
          if (result && result.status === '1') {
            callbackfun(result);
				  }
        },
      );
    }

	// 加载列表数据
	@action doTableLoading = (params) => {
	  this.showLoading(true);

	  let resultParams = this.getFormParams();
	  const commonParams = {
	    searchType: this.selectedKey,
	  };
	  resultParams = { ...resultParams, ...commonParams, ...params, flowTitle: params, subCompanyId: this.subCompanyId };
	  Apis.getUseCarWorkflowSetList(resultParams).then(
	    (result) => {
	      this.isRight = result.isRight;
	      if (this.isRight == 0) {

	      } else {
	        const sessionkey = result.sessionkey;
	        this.sessionkey = sessionkey;
	        this.tableStore.getDatas(sessionkey, 1);
	      }
	      this.showLoading(false);
	    },
	  );
	}
}
